/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hk.ces.oxfam.patch.config;

import java.io.IOException;
import java.util.Properties;
import org.apache.log4j.Logger;

/**
 *
 * @author ReutyCheng
 */
enum DatabaseDriver
{
  DB2("DB2"), POSTGRE_SQL("PostgreSQL");
  
  private final Properties properties = new Properties();
  private String name;

  private DatabaseDriver(String name)
  {
    this.name = name;
    try
    {
      this.properties.load(this.getClass().getResourceAsStream("/database_driver.properties"));
    }
    catch (IOException ex)
    {
      Logger.getLogger(this.getClass()).error(ex.getMessage(), ex);
      throw new RuntimeException("Can't load database driver config");
    }
  }

  public String getDriverName()
  {
    return name;
  }

  public String getValue()
  {
    return this.properties.getProperty(this.toString());
  }

  public String getDriverClass()
  {
    return this.properties.getProperty(this.toString() + "_DRIVER_CLASS");
  }

  public String getURLTemplate()
  {
    return this.properties.getProperty(this.toString() + "_URL_TEMPLATE");
  }
}
